import os


def create_folders(base_path, start_num=2, end_num=55, prefix="A"):
    """
    在指定路径下创建多个空文件夹

    参数:
    base_path: 基础路径
    start_num: 起始编号
    end_num: 结束编号
    prefix: 文件夹名前缀
    """
    # 检查基础路径是否存在
    if not os.path.exists(base_path):
        print(f"基础路径不存在: {base_path}")
        return

    created_folders = []
    failed_folders = []

    # 创建文件夹
    for i in range(start_num, end_num + 1):
        folder_name = f"{prefix}{i}"
        folder_path = os.path.join(base_path, folder_name)

        try:
            # 如果文件夹不存在，则创建
            if not os.path.exists(folder_path):
                os.makedirs(folder_path)
                created_folders.append(folder_name)
                print(f"✓ 创建文件夹: {folder_name}")
            else:
                print(f"⚠ 文件夹已存在: {folder_name}")

        except Exception as e:
            failed_folders.append(folder_name)
            print(f"✗ 创建失败 {folder_name}: {str(e)}")

    # 输出结果统计
    print(f"\n创建完成!")
    print(f"成功创建: {len(created_folders)} 个文件夹")
    print(f"创建失败: {len(failed_folders)} 个文件夹")

    if created_folders:
        print(f"创建的文件夹: {', '.join(created_folders)}")

    return created_folders, failed_folders


# 使用示例

 # 指定基础路径
base_directory = r"F:\数据合集\壁青湾数据合集\壁青湾min级"  # 替换为你的实际路径

    # 创建A2到A55的文件夹
created, failed = create_folders(base_directory, 1, 55, "M")